<?php

namespace app\common\model;

use think\Model;

/**
 * 邮箱验证码
 */
class People Extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    // 追加属性
    protected $append = [
    ];
    public function people($openid){
        $res = $this->where('openid',$openid)->find();
        return $res;
    }
    public function add_update_user($openid,$image,$name){
        $count = $this->where('openid',$openid)->count();
        if($count > 0){
            $arr = array(
                'name'  => $name,
                'image' => $image
            );
            $res = $this->where('openid',$openid)->update($arr);
        }else{
            $arr = array(
                'name'  => $name,
                'openid'=> $openid,
                'image' => $image,
                'createtime'=> time()
            );
            $res = $this->insert($arr);
        }
        return $res;
    }
}
